import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../interface/root_proxy_model.dart';
import 'rank/widget/room_rank_item_widget.dart';
import 'user_list_online_page_model.dart';

class UserListOnlinePage extends StatelessWidget {
  const UserListOnlinePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: [
          ChangeNotifierProxyProvider<RootProxyModel, UserListPageOnlineModel>(
            create: (context) => UserListPageOnlineModel(),
            update: (context, rootProxyModel, leafModel) {
              if (leafModel == null) throw ArgumentError.notNull('leafModel');
              leafModel.roomModel = rootProxyModel;
              return leafModel;
            },
          ),
        ],
        child:
            Consumer<UserListPageOnlineModel>(builder: (context, model, child) {
          return RefreshIndicator(
            onRefresh: () async {
              await model.requestData();
            },
            // child: ListView.builder(
            //   physics: const AlwaysScrollableScrollPhysics(
            //     parent: BouncingScrollPhysics()
            //   ),
            //   itemCount: model.data?.users.length ?? 0,
            //   itemBuilder: (context, index) {
            //     return RoomRankItemWidget(
            //       item: model.data!.users[index],
            //       index: index,
            //       showRankIcon: false,
            //       showValue: false,
            //       inRoom: true,
            //     );
            //   }),

            child: const Text('ListView.builder'),
          );
        }));
  }
}
